
import PWS.Caesar;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;


public class Main {
	
	//public static Vinegere t = new Vinegere("Marco");
	//public static Caesar c = new Caesar("Marco");
	
	public static void main(String[] args) {
		//c.setKey(3);
		//t.setPass("slet");
		//System.out.println(t.encrypt());
		//System.out.println(c.encrypt());
            
            String enc = readFile("C:/Documents and Settings/LBAOMELM/Bureaublad/Cryptography/test.txt");
            //String encc = enc.trim().replaceAll(" ", "").replaceAll("\\s", "");
            String enc2 = enc.trim().replaceAll(" ", "^");
            System.out.println(enc2);
            Caesar encrypt = new Caesar(enc2, 6);
            String encrypted = encrypt.encrypt();
            Caesar decrypt = new Caesar(encrypted, 6);
            String out = enc + " | " + encrypted + " | " + decrypt.decrypt();
            
            System.out.println(enc2);
	}
        
        public static String readFile(String path) {
        //...checks on aFile are elided
        StringBuilder contents = new StringBuilder();

        try {
            //use buffering, reading one line at a time
            //FileReader always assumes default encoding is OK!
            BufferedReader input = new BufferedReader(new FileReader(new File(path)));
            try {
                String line = null; //not declared within while loop
        /*
                 * readLine is a bit quirky :
                 * it returns the content of a line MINUS the newline.
                 * it returns null only for the END of the stream.
                 * it returns an empty String if two newlines appear in a row.
                 */
                while ((line = input.readLine()) != null) {
                    contents.append(line);
                    contents.append(System.getProperty("line.separator"));
                }
            } finally {
                input.close();
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        return contents.toString();
    }

}